from ortools.constraint_solver import routing_enums_pb2

# Mapping of or-tools heuristic numbers to their names
first_solution_matching = {
    routing_enums_pb2.FirstSolutionStrategy.UNSET: 'UNSET', 
    # 0 - Default
    routing_enums_pb2.FirstSolutionStrategy.AUTOMATIC: 'AUTOMATIC', 	                 
    # 15 - Lets the solver detect which strategy to use according to the model being solved.
    routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC: 'PATH_CHEAPEST_ARC', 	     
    # 3 - Starting from a route "start" node, connect it to the node which produces the cheapest route segment,
    # then extend the route by iterating on the last node added to the route.
    routing_enums_pb2.FirstSolutionStrategy.PATH_MOST_CONSTRAINED_ARC: 'PATH_MOST_CONSTRAINED_ARC',
    # 4 - Similar to PATH_CHEAPEST_ARC, but arcs are evaluated with a comparison-based selector which will favor the
    # most constrained arc first. To assign a selector to the routing model, use the method
    # ArcIsMoreConstrainedThanArc().
    routing_enums_pb2.FirstSolutionStrategy.EVALUATOR_STRATEGY: 'EVALUATOR_STRATEGY', 	     
    # 5 - Similar to PATH_CHEAPEST_ARC, except that arc costs are evaluated using the function passed to
    # SetFirstSolutionEvaluator().
    routing_enums_pb2.FirstSolutionStrategy.SAVINGS: 'SAVINGS',                 	 
    # 10 - Savings algorithm (Clarke & Wright). Reference: Clarke, G. & Wright, J.W.: "Scheduling of Vehicles from a
    # Central Depot to a Number of Delivery Points", Operations Research, Vol. 12, 1964, pp. 568-581.
    routing_enums_pb2.FirstSolutionStrategy.SWEEP: 'SWEEP', 	                     
    # 11 - Sweep algorithm (Wren & Holliday). Reference: Anthony Wren & Alan Holliday: Computer Scheduling of
    # Vehicles from One or More Depots to a Number of Delivery Points Operational Research Quarterly (1970-1977),
    # Vol. 23, No. 3 (Sep., 1972), pp. 333-344.
    routing_enums_pb2.FirstSolutionStrategy.CHRISTOFIDES: 'CHRISTOFIDES', 	             
    # 13 - Christofides algorithm (actually a variant of the Christofides algorithm using a maximal matching instead
    # of a maximum matching, which does not guarantee the 3/2 factor of the approximation on a metric travelling
    # salesman). Works on generic vehicle routing models by extending a route until no nodes can be inserted on it.
    routing_enums_pb2.FirstSolutionStrategy.ALL_UNPERFORMED: 'ALL_UNPERFORMED', 	         
    # 6 - Make all nodes inactive. Only finds a solution if nodes are optional (are element of a disjunction
    # constraint with a finite penalty cost).
    routing_enums_pb2.FirstSolutionStrategy.BEST_INSERTION: 'BEST_INSERTION', 	         
    # 7 - Iteratively build a solution by inserting the cheapest node at its cheapest position; the cost of insertion
    # is based on the global cost function of the routing model. As of 2/2012, only works on models with optional
    # nodes (with finite penalty costs).
    routing_enums_pb2.FirstSolutionStrategy.PARALLEL_CHEAPEST_INSERTION: 'PARALLEL_CHEAPEST_INSERTION', 
    # 8 - Iteratively build a solution by inserting the cheapest node at its cheapest position; the cost of insertion
    # is based on the arc cost function. Is faster than BEST_INSERTION.
    routing_enums_pb2.FirstSolutionStrategy.LOCAL_CHEAPEST_INSERTION: 'LOCAL_CHEAPEST_INSERTION', 	 
    # 9 - Iteratively build a solution by inserting each node at its cheapest position; the cost of insertion is
    # based on the arc cost function. Differs from PARALLEL_CHEAPEST_INSERTION by the node selected for insertion;
    # here nodes are considered in their order of creation. Is faster than PARALLEL_CHEAPEST_INSERTION.
    routing_enums_pb2.FirstSolutionStrategy.GLOBAL_CHEAPEST_ARC: 'GLOBAL_CHEAPEST_ARC', 	     
    # 1 - Iteratively connect two nodes which produce the cheapest route segment.
    routing_enums_pb2.FirstSolutionStrategy.LOCAL_CHEAPEST_ARC: 'LOCAL_CHEAPEST_ARC', 	     
    # 2 - Select the first node with an unbound successor and connect it to the node which produces the cheapest
    # route segment.
    routing_enums_pb2.FirstSolutionStrategy.FIRST_UNBOUND_MIN_VALUE: 'FIRST_UNBOUND_MIN_VALUE' 	 
    # 12 - Select the first node with an unbound successor and connect it to the first available node. This is
    # equivalent to the CHOOSE_FIRST_UNBOUND strategy combined with ASSIGN_MIN_VALUE
}

# Mapping of or-tools metaheuristic numbers to their names
local_search_matching = {
    routing_enums_pb2.LocalSearchMetaheuristic.UNSET: 'UNSET',
    # 0 - Default
    routing_enums_pb2.LocalSearchMetaheuristic.AUTOMATIC: 'AUTOMATIC', 	         
    # 6 - Lets the solver select the metaheuristic
    routing_enums_pb2.LocalSearchMetaheuristic.GREEDY_DESCENT: 'GREEDY_DESCENT',
    # 1 - Accepts improving (cost-reducing) local search neighbors until a local minimum is reached
    routing_enums_pb2.LocalSearchMetaheuristic.GUIDED_LOCAL_SEARCH: 'GUIDED_LOCAL_SEARCH',
    # 2 - Uses guided local search to escape local minima (cf. http://en.wikipedia.org/wiki/Guided_Local_Search)
    # this is generally the most efficient metaheuristic for vehicle routing
    routing_enums_pb2.LocalSearchMetaheuristic.SIMULATED_ANNEALING: 'SIMULATED_ANNEALING',
    # 3 - Uses simulated annealing to escape local minima (cf. http://en.wikipedia.org/wiki/Simulated_annealing)
    routing_enums_pb2.LocalSearchMetaheuristic.TABU_SEARCH: 'TABU_SEARCH',
    # 4 - Uses tabu search to escape local minima (cf. http://en.wikipedia.org/wiki/Tabu_search)
    routing_enums_pb2.LocalSearchMetaheuristic.GENERIC_TABU_SEARCH: 'GENERIC_TABU_SEARCH'
    # 5 - Uses tabu search on the objective value of solution to escape local minima
}
